package db

import (
	"github.com/xujiajun/nutsdb"
	"time"
)

var db *nutsdb.DB

func InitNutsdb(dir string) error {
	var err error
	opt := nutsdb.DefaultOptions
	opt.Dir = dir //这边数据库会自动创建这个目录文件
	db, err = nutsdb.Open(opt)
	return err
}

type SendModel struct {
	DeviceId     string
	IpAddress    string
	DeviceType   string
	InOutMetrics []InOut
}

type InOut struct {
	Zone      string
	Date      string
	StartTime string
	EndTime   string
	Enter     int
	Exit      int
	Time      time.Time
}

type DeviceFlow struct {
	DeviceId   string
	Time       time.Time
	Zone       string
	CountEnter int
	CountExit  int
	// 0 为 未发送成功，1为发送成功
	Status     int
	IpAddress  string
	DeviceType string
}
